<?php
/**
 * Created by JetBrains PhpStorm.
 * User: T420
 * Date: 9/27/12
 * Time: 10:16 PM
 * To change this template use File | Settings | File Templates.
 */
class Models_ShoppingCart extends Libs_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function getlistcart($listid)
    {
        $this->db->connect();
        $listpro=$this->db->executeQuery("select * from lb_product where pid in (".$listid.")");
        $this->db->disconnect();
        return $listpro;

    }
    public function getintrouser($user)
    {
        $this->db->connect();
        $intro=$this->db->executeQuery("select * from lb_users where username='$user'");
        $this->db->disconnect();
        return $intro;
    }
    public function getpayment()
    {
        $this->db->connect();
        $listpay=$this->db->executeQuery("select * from lb_payment");
        $this->db->disconnect();
        return $listpay;
    }
    public function insertorder($userid,$namecustomer,$payid,$email,$phone,$datereceipt,$address)
    {

        $this->db->connect();
        if($userid=='') $str="insert lb_order(namecustomer,payid,email,phone,postdate,datereceipt,readdress) values ('$namecustomer','$payid','$email','$phone',now(),'$datereceipt','$address')";
        else $str="insert lb_order(userid,namecustomer,payid,email,phone,postdate,datereceipt,readdress) values ('$userid','$namecustomer','$payid','$email','$phone',now(),'$datereceipt','$address')";
        $this->db->queryinsert($str);
        $this->db->disconnect();
    }
    public function insertdetail($pid,$oid,$qty,$price)
    {
        $this->db->connect();
        $this->db->queryinsert("insert lb_orderdetail(pid,oid,quantity,price) values('$pid','$oid','$qty','$price')");
        $this->db->disconnect();
    }
    public function getoid()
    {
        $this->db->connect();
        $oid=$this->db->executeQuery("select oid from lb_order order by oid desc limit 0,1");
        $this->db->disconnect();
        return $oid;
    }
}